package com.aiYouPms.common.api;

import lombok.Data;

@Data
public class HttpResult<T> {
    private int code;
    private String msg;
    private T data;

    public HttpResult() {
    }

    public HttpResult(int code, String message, T data) {
        this.code = code;
        this.msg = message;
        this.data = data;
    }

    public static <T> HttpResult<T> success(T data) {
        return new HttpResult<>(200, "success", data);
    }

    public static <T> HttpResult<T> success(String message, T data) {
        return new HttpResult<>(200, message, data);
    }

    public static <T> HttpResult<T> error(String message) {
        return new HttpResult<>(500, message, null);
    }

    public static <T> HttpResult<T> error(int code, String message) {
        return new HttpResult<>(code, message, null);
    }

    public static <T> HttpResult<T> error( String message, T data) {
        return new HttpResult<>(500, message, data);
    }
}
